package com.way.designpatterncodepratice.factory.traditional;

import com.way.designpatterncodepratice.factory.base.CheesePizza;
import com.way.designpatterncodepratice.factory.base.FruitPizza;
import com.way.designpatterncodepratice.factory.base.Pizza;

import java.util.Scanner;

/**
 * @author liangliwei 80551025
 * @description
 * @date 2020-06-22
 */
public class PizzaStore {

    private Pizza pizza;


    public void orderPizza(){
        while (true){
            String pizzaType = getType();
            if("cheese".equals(pizzaType)){
                pizza = new CheesePizza();
            }else if("fruit".equals(pizzaType)){
                pizza = new FruitPizza();
            }else{
                System.out.println("没有该类型pizza，退出！");
                break;
            }
            /**
             * 输出pizza制作过程
             */
            pizza.prepare();
            pizza.cut();
            pizza.bake();
            pizza.box();
        }
    }

    private String getType() {
        Scanner scanner = new Scanner(System.in);
        String pizzaType = scanner.next();
        return pizzaType;
    }
}
